/*
* @Author: z.p
* @Project: Zdotp
* @Date: 2025年01月15日
* @Description: kcp处理文件
*/

using Zdotp.Actor.Controller;
using Zdotp.Actor.Packet;

namespace Zdotp.Actor.Kcp;

public class KcpReadHandler : ActorController<ActorKcp, ReadMessage>
{
    protected override void Run(ActorKcp actor, ActorSystem system, MessageInfo info, ReadMessage data)
    {
        var protocolId = data.ProtocolId;
        var message = data.Data;
        ActorSystem.NetHandle(protocolId, actor, info.SessionId, message);
    }
}
public class KcpWriteHandler : ActorController<ActorKcp, WriteMessage>
{
    protected override void Run(ActorKcp actor, ActorSystem system, MessageInfo info, WriteMessage data)
    {
        if (info.SessionId == 0)
        {
            actor.SendMsgToAllClient(data.Data);
        }
        else
        {
            actor.SendMsgToClient(info.SessionId, data.Data);
        }
    }
}

public class ReadMessage : MailObject
{
    public uint ProtocolId;
    public byte[] Data;
}
public class WriteMessage : MailObject
{
    public byte[] Data { get; set; }
}

public class ConnectMessage : MailObject;
public class DisConnectMessage : MailObject;